package com.ahsjdy.st.stbomanagerweb.controller;

import com.ahsjdy.st.stdao.entity.Navigation;
import com.ahsjdy.st.stdao.entity.User;
import com.ahsjdy.st.stdao.mapper.NavigationMapper;
import com.ahsjdy.stcommon.dto.ResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Description
 * @Author xuetao wang
 * @Date 2019/12/29
 */
@Controller
@RequestMapping(value = "/view")
public class PageController extends BaseController {

    @Autowired
    private NavigationMapper navigationMapper;

    @RequestMapping(value = "/login")
    public String login() {
        return "login";
    }

    @RequestMapping("/home")
    public String home() {
        return "home";
    }

    @RequestMapping("/area")
    public String area() {
        return "area";
    }

    @RequestMapping("/user/logout")
    public String logout( HttpSession session) {
        session.invalidate();
       return "redirect:/";
    }

    @RequestMapping("/toAddNavChild")
    public String toAddNavChild(int navId, HttpServletRequest request) {
        Navigation navigation = navigationMapper.selectByPrimaryKey(navId);
        request.setAttribute("nav", navigation);
        return "addNavChild";
    }

    @RequestMapping("/addArea")
    public String addArea() {
        return "areaAdd";
    }

    @RequestMapping("/editArea")
    public String editArea(int id) {
        request.setAttribute("id", id);
        return "areaEdit";
    }

    @RequestMapping("/merchant")
    public String merchant() {
        return "merchant";
    }

    @RequestMapping("/addMerchant")
    public String addMerchant() {
        return "merchantAdd";
    }

    @RequestMapping("/detailMerchant")
    public String detailMerchant(int id) {
        request.setAttribute("id", id);
        return "merchantDetail";
    }

    @RequestMapping("/settleMerchant")
    public String settleMerchant(int id) {
        request.setAttribute("id", id);
        return "merchantSettle";
    }

    @RequestMapping("/rider")
    public String rider() {
        return "qishou";
    }
}
